package com.team5101.bootstrap;


import com.team5101.client.RpcConsumer;
import com.team5101.service.DemoService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
@Slf4j
public class ClientConsumerBootStrap extends Thread {

    @Autowired
    private RpcConsumer rpcConsumer;

    @Override
    public void run() {

        try {
            rpcConsumer.startUp();
        } catch (Exception e) {
            e.printStackTrace();
        }

        DemoService proxy = (DemoService) rpcConsumer.createProxy(DemoService.class);

        while (true) {

            try {
                Thread.sleep(1000);
                String res = proxy.demoMethod("hello world");
//                log.info("响应数据： " + res);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
}
